<!DOCTYPE html>
<html lang="en"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>幸运砸金蛋抽奖</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" type="text/css" href="css/reset.css" media="all">
<link rel="stylesheet" type="text/css" href="css/main.css" media="all">
<link rel="stylesheet" type="text/css" href="css/dialog.css" media="all">
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/dialog_min.js" type="text/javascript"></script>
<script src="js/player_min.js" type="text/javascript"></script>
<script src="js/main.js" type="text/javascript"></script>
<script src="js/alert.js" type="text/javascript"></script>

</head>
<body>

<!--/弹出层1-->
<section id="dialoger">
<div id="dialogWindow" class="dialogWindow  get">
<header>
<dl><dd><label></label></dd><dd><span></span></dd></dl></header>
<article class="dialogContent">
<div class="header"><h6>你中了：三等奖</h6><h6>兑奖SN码：201403017921638635</h6></div>
<table><tbody><tr><td><input type="text" id="tel" placeholder="请输入手机号，以便领取奖品" maxlength="30" value=""></td></tr>
<tr><td><button class="subBtn" onclick="usersub(201403017921638635)">用户提交</button></td></tr>
<tr><td><input type="password" id="pwd" placeholder="商家输入兑奖密码" maxlength="30"></td></tr>
<!--<tr><td><button class="subBtn" onclick="pwdsub(&#39;三等奖&#39;,201403017921638635)">商家提交</button></td></tr>-->
</tbody></table></article><footer></footer></div><div class="dialogCover"></div></section>
<!--弹出层1/-->
<!--/弹出层2-->
<div class="window" id="windowcenter">
	<div id="title" class="title">消息提醒<span class="close" id="alertclose"></span></div>
	<div class="content">
	 <div id="txt"></div>
	 <input type="button" value="确定" id="windowclosebutton" name="确定" class="txtbtn">	
	</div>
</div>
<!--弹出层2/-->

<!----/主题部分砸金蛋-->
<div class="body pb_10">
<div style="position:absolute;left:10px;top:10px;z-index:350;">
<a href="javascript:;" id="playbox" class="btn_music on" onclick="playbox.init(this).play();" ontouchstart="event.stopPropagation();"></a>
<audio id="audio" loop src="css/img/default.mp3" style="pointer-events:none;display:none;width:0!important;height:0!important;"></audio>
</div>
<section class="stage">
<img src="css/img/stage.jpg">
 <div id="shape" class="cube on">
        <div class="plane one"><span><figure>&nbsp;</figure></span></div>
        <div class="plane two"><span class="on"><!--on碎了--><figure>&nbsp;</figure></span></div>
        <div class="plane three"><span class="on luck"><!--on碎了中奖--><figure>&nbsp;</figure></span></div>
      </div>
      <div id="hit" class="hit"><img src="css/img/1.png"></div><!--砸子-->
</section>
<section>
<div class="instro_wall">
<article class="a3">
<h6>奖品设置</h6>
<div>
<p>一等奖：iPhone8s测试 。奖品数量：10 </p>
<p>二等奖：iPhone7s测试 。奖品数量：100 </p>
<p>三等奖：iPhone6s测试 。奖品数量：1000 </p>
</div>
</article>
<article>
<h6>活动说明</h6>
<div>
<p>本次活动每人可以砸 3 次 </p>
<p>亲，请点击进入砸金蛋活动页面，祝您好运哦！</p>
</div>
</article>
</div>
</section>
<footer style="text-align:center; color:#fff;margin-right:20px"></footer>
</div>
<!----/主题部分砸金蛋-->
<script type="text/javascript">
var play_level = 10;//play_level = 0任何人都可以参加。//play_level = 10会员才可以参加。

var user_level = 10 ;
var user_status = "approved";//approved允许玩
var shop_id = '18';

var p_m_t = "3";
var lottery_status = "1";

var prize_code = "";
var VAR_prize = "";

var VAR_wx_user_id = "";
var VAR_id = "10739";
var VAR_token = "o7VbEjhnrZE5xfYj08waV6R-9Doo";
var VAR_user = "";

var VAR_shortmenu = "砸金蛋";
var count = 1;					
var prize;
var sncode;
</script>
<script>
document.addEventListener("DOMContentLoaded", function(){
playbox.init("playbox");
//
var shape = document.getElementById("shape");
var hitObj = {
handleEvent: function(evt){
if("SPAN" == evt.target.tagName){
	if(!check_paly_level()){
            return;
        }
	if (count >= 3) {
			running = false;
			alert("您已经砸了 3 次奖,不能再砸了,下次再来吧!");
            return false;
        }
        if (prize != null) {
		   alert("亲，你不能再参加本次活动了喔！下次再来吧~");
            return false;
        }
	shape.removeEventListener("click", hitObj, false);
	$.ajax({
            url: "/Egg/activityuser/",
            dataType: "json",
            data: {
                token: "o7VbEjhnrZE5xfYj08waV6R-9Doo",//微信用户id
                tid: "10739",//游戏id
                t: Math.random()
            }, 
            success: function(data) {
                if (data.error == "invalid") {
					//参与次数已用完
                    alert(data.msg);
					shape.addEventListener("click", hitObj, false);
                    return false;
                }
                if (data.error == "getsn") {
					//获取中奖信息
                    //$("#tel").val(data.tel);
                    alert(data.msg + data.sn);
                    prize = data.prizetype;
                    sncode = data.sn;
					shape.addEventListener("click", hitObj, false);
					return false;
                }
				var audio = new Audio();
				audio.src = "/Public/Egg/blue/smashegg.mp3";
				audio.play();
				$("#hit").addClass("on").css({left: evt.pageX+"px", top:evt.pageY +"px"});
				evt.target.classList.toggle("on");
                if (data.success) {
					//首次中奖
                    prize = data.prizetype;
                    sncode = data.sn;
					evt.target.classList.toggle("luck");
					setTimeout(function(){
						var urls = ["/Public/Egg/blue/smashegg/coin.png"];
						getCoin(urls);
						jg(data);
					}, 2000);
                } else {
					//正常请求下请求，没中奖的返回情况
                    prize = null;
					setTimeout(function(){
						lqsb("亲，继续努力哦！");
					}, 2000);
                }
            },
            error: function() {
                prize = null;
				setTimeout(function(){
						lqsb("亲，继续努力哦！");
					}, 2000);
		/*
				alert('请求失败！');
				shape.addEventListener("click", hitObj, false);
				*/
            },
            timeout: 20000
        });
}
shape.removeEventListener("click", hitObj, false);
}
}
shape.removeEventListener("click", hitObj, false);
}, false);

</script>
<script>

//领取
var d2 = new iDialog();
function jg(arg){
var jpname,tel="";
if(arg.prizetype){
 if (arg.prizetype == '1') {
     jpname = "一等奖";
 } else if (arg.prizetype == '2') {
     jpname = "二等奖";
 } else if (arg.prizetype == '3') {
     jpname = "三等奖";
 }
}else{
 jpname  = arg.prizename;
} 
if(arg.mobile){
tel = arg.mobile;
}
d2.open({
classList: "get",
title:"",
close:"",
content:'<div class="header"><h6>你中了：'+jpname+
'</h6><h6>兑奖SN码：'+arg.sn+
'</h6></div><table><tr><td><input type="text" id="tel" placeholder="请输入手机号，以便领取奖品" maxlength="30"  value="'
+tel+
'"/></td></tr><tr><td><button class="subBtn" onclick="usersub('
+arg.sn+
')">用户提交</button></td></tr><tr><td><input type="password" id="pwd" placeholder="商家输入兑奖密码" maxlength="30" /></td></tr><tr><td><button class="subBtn" onclick="pwdsub(\''
+jpname+'\','+arg.sn+
')">商家提交</button></td></tr></table>',
btns:[]
});
}
function usersub(sn){
    var tel = $.trim($("#tel").val());
    if (tel == '') {
        alert("请输入手机号");
        return
    }
	
    var submitData = {
        tid: 10739,
		token: "o7VbEjhnrZE5xfYj08waV6R-9Doo",//微信用户id
        code: sn,
        tel: tel,
        action: "setTel"
    };
    $.post('/Egg/activityuser/', submitData,
    function(data) {
        if (data.success == true) {
            alert(data.msg);
            return
        } else {}
    },
    "json")
}
function pwdsub(jpname,sn){
	var pwd = $("#pwd").val();
    if (pwd == '') {
        alert("请输入商家密码");
        return
    }
	 var submitData = {
        tid: 10739,
		token: "o7VbEjhnrZE5xfYj08waV6R-9Doo",//微信用户id
        code: sn,
		parssword:pwd,
        action: "setTel"
    };
    $.post('/Egg/activityuser/', submitData,
    function(data) {
        if (data.success == true) {
			if (data.success2 == true) {	
				d2.die();
				lqcg(jpname,sn);
			}else{
				alert(data.msg);
			}	
            return
        } else {}
    },
    "json")
}


//领取结果


//领取结果-成功
function lqcg(jpname,sn){
var d5 = new iDialog();
d5.open({
classList: "success",
title:"",
close:"",
content:'<div class="header"><h6>你中了：'+jpname+
'</h6><h6>兑奖SN码：'+sn+
'</h6><h6 style="color:#CC0000;">您已经兑奖成功，本SN码自动作废</h6></div>',
btns:[
{id:"", name:"知道了", onclick:"fn.call();", fn: function(self){
self.die();
}},
]
});
}

//砸蛋结果-失败
function lqsb(msg){
var d6 = new iDialog();
d6.open({
classList: "failed",
title:"",
close:"",
content:'<div class="header">'+msg+'</div>\
<table><tr>\
<td><img  src="http://pic.vxiaoxin.com/Public/Egg/blue/smashegg/8.png" /></td>\
</tr></table>',
btns:[
{id:"", name:"再砸一次", onclick:"fn.call();", fn: function(self){
location.href = location.href + "&r="+Math.random();
}},
]
});
}



function check_paly_level(){
	if(user_level == 0){
		alert("点击右上角“查看公众账号”关注我们，然后回复" + VAR_shortmenu + "进入抽奖！。");
		return false;
	}
	//任何人都可以参加。
	if(play_level == 0) return true;

	//会员才可以参加。
	if(play_level == 10){
		if(user_level >= 10 && user_status == 'approved'){
			return true;
		}else if(user_status == 'unaudited' || user_status == 'remove'){
			if(user_status == 'unaudited'){
				alert("你的会员，还在审核中。不能参加抽奖活动。");
			}else {
				alert("你的会员已失效。不能参加抽奖活动。");			
			}
			return true;
		}else if(user_level >= 5) {
			$("#regMemberWindow").slideToggle("slow"); 
		}else {
			alert("用户授权信息过期，请从微信回复" + VAR_shortmenu + "进入抽奖！"
			+"未关注用户，请点击右上角“查看公众账号”关注！");
		}
	}
}	
var sn_dat = {"sn":"201403017921638635","prizename":"三等奖","mobile":""};
jg(sn_dat);

</script>


</body></html>